<?php
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : area.class.php   FILE_PATH : \\classes\application\pay_order.class.php
 * ....关于缴费订单
 *
 * @copyright workflow_system
 * @author workflow Develop Team 
 * @package
 * @subpackage
 * @version Tue Jul 10 22:45:45 CST 2008
 */

class payOrderClass extends FrameWork {
	
	/**
	 * 保存缴费订单
	 * 
	 */
	function savePayOrder($input)
	{
		if ($GLOBALS['db']->InsertRow($input, 'member_pay_order', 'pay_id'))
		{
			unset($input);
			return true;
		}
		unset($input);
		return false;
	}
	
	/**
	 * 获得订单最大ID
	 *
	 *
	 */
	function getLastId()
	{
		$order_row = $GLOBALS['db']->GetLastRow('member_pay_order','mpo_id','');
		$order_last_id = $order_row['mpo_id'];
		return $order_last_id;
	}
	
	/**
	 * 取某一订单信息
	 * 
	 */
	function getOneOrderInfo($id)
	{
		if ($id != ''){
			return $GLOBALS['db']->GetOneRow($id,'member_pay_order','mpo_code');
		}
	}
	
	/**
	 * 更新订单内容
	 * 
	 */
	function updateOrderState($input)
	{
		$update_array = array();
		$update_array['mpo_pay_sign'] = $input['mpo_pay_sign'];
		$update_array['mpo_end_time'] = time();
		if (empty($input['mpo_shop_time'])) 
		{
			$update_array['mpo_product_number']    = $input['mpo_product_number'];
			$update_array['mpo_product_show_time'] = $input['mpo_product_show_time'];
		}else
		{
			$update_array['mpo_shop_time'] = $input['mpo_shop_time'];
		}
		
		if ($GLOBALS['db']->UpdateRow($input['item_number'],$update_array,'member_pay_order','mpo_code'))
		{
			unset($input);
			return true;
		}
		else 
		{
			unset($input);
			return false;
		}
	}
	
	/**
	 * 缴费记录列表
	 * 
	 */
	function listShopPayNote($condition,&$obj_page)
	{
		$conditionstr = $this->_conditionSearch($condition);
		$link_array   = $GLOBALS['db']->GetList($conditionstr, $obj_page, "member_pay_order");
		return $link_array;
	}
	
	/**
	 * 构造检索条件
	 * @author     
	 * @param  
	 * @return string
	 */
	function _conditionSearch($condition)
	{
		$condition_str = "";
		if ($condition['mpo_member_id'] != '')
		{
			$condition_str .= " and member_pay_order.mpo_member_id = '" . $condition['mpo_member_id'] . "'";
		}
		if ($condition['txtMemberName'] != '')
		{
			$condition_str .= " and member_pay_order.mpo_member_name = '" . $condition['txtMemberName'] . "'";
		}
		if ($condition['selectmode'] != '')
		{
			$condition_str .= " and member_pay_order.mpo_mode_id = '" . $condition['selectmode'] . "'";
		}
		if ($condition['selectpay'] != '')
		{
			$condition_str .= " and member_pay_order.mpo_pay_id = '" . $condition['selectpay'] . "'";
		}
		if ($condition['selectType'] != '')
		{
			$condition_str .= " and member_pay_order.mpo_pay_sign = '" . $condition['selectType'] . "'";
		}
		if ($condition['selectpaymode'] != '')
		{
			$condition_str .= " and member_pay_order.mpo_on_type = '" . $condition['selectpaymode'] . "'";
		}
		return $condition_str;
	}
	
	/**
	 * 删除缴费记录
	 * 
	 */
	function delNote($id)
	{
		if (intval($id) > 0){
			return $GLOBALS['db']->DelRow(intval($id),'member_pay_order','mpo_id');
		}else {
			return false;
		}
	}
	
}